package com.ldg.crm.dao;

import com.ldg.crm.entity.CompactEntity;
import com.ldg.crm.entity.CompactEntityExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface CompactDao {
    /**
     *
     * @mbg.generated
     */
    @SelectProvider(type=CompactEntitySqlProvider.class, method="countByExample")
    long countByExample(CompactEntityExample example);

    /**
     *
     * @mbg.generated
     */
    @DeleteProvider(type=CompactEntitySqlProvider.class, method="deleteByExample")
    int deleteByExample(CompactEntityExample example);

    /**
     *
     * @mbg.generated
     */
    @Delete({
        "delete from crm_compact",
        "where compact_id = #{compactId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer compactId);

    /**
     *
     * @mbg.generated
     */
    @Insert({
        "insert into crm_compact (compact_id, customer_id, ",
        "bus_id, compact, ",
        "compact_time, party_a, ",
        "party_b, text)",
        "values (#{compactId,jdbcType=INTEGER}, #{customerId,jdbcType=INTEGER}, ",
        "#{busId,jdbcType=INTEGER}, #{compact,jdbcType=INTEGER}, ",
        "#{compactTime,jdbcType=DATE}, #{partyA,jdbcType=VARCHAR}, ",
        "#{partyB,jdbcType=VARCHAR}, #{text,jdbcType=VARCHAR})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="compactId", before=true, resultType=Integer.class)
    int insert(CompactEntity record);

    /**
     *
     * @mbg.generated
     */
    @InsertProvider(type=CompactEntitySqlProvider.class, method="insertSelective")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="compactId", before=true, resultType=Integer.class)
    int insertSelective(CompactEntity record);

    /**
     *
     * @mbg.generated
     */
    @SelectProvider(type=CompactEntitySqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="compact_id", property="compactId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="customer_id", property="customerId", jdbcType=JdbcType.INTEGER),
        @Result(column="bus_id", property="busId", jdbcType=JdbcType.INTEGER),
        @Result(column="compact", property="compact", jdbcType=JdbcType.INTEGER),
        @Result(column="compact_time", property="compactTime", jdbcType=JdbcType.DATE),
        @Result(column="party_a", property="partyA", jdbcType=JdbcType.VARCHAR),
        @Result(column="party_b", property="partyB", jdbcType=JdbcType.VARCHAR),
        @Result(column="text", property="text", jdbcType=JdbcType.VARCHAR)
    })
    List<CompactEntity> selectByExample(CompactEntityExample example);

    /**
     *
     * @mbg.generated
     */
    @Select({
        "select",
        "compact_id, customer_id, bus_id, compact, compact_time, party_a, party_b, text",
        "from crm_compact",
        "where compact_id = #{compactId,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="compact_id", property="compactId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="customer_id", property="customerId", jdbcType=JdbcType.INTEGER),
        @Result(column="bus_id", property="busId", jdbcType=JdbcType.INTEGER),
        @Result(column="compact", property="compact", jdbcType=JdbcType.INTEGER),
        @Result(column="compact_time", property="compactTime", jdbcType=JdbcType.DATE),
        @Result(column="party_a", property="partyA", jdbcType=JdbcType.VARCHAR),
        @Result(column="party_b", property="partyB", jdbcType=JdbcType.VARCHAR),
        @Result(column="text", property="text", jdbcType=JdbcType.VARCHAR)
    })
    CompactEntity selectByPrimaryKey(Integer compactId);

    /**
     *
     * @mbg.generated
     */
    @UpdateProvider(type=CompactEntitySqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") CompactEntity record, @Param("example") CompactEntityExample example);

    /**
     *
     * @mbg.generated
     */
    @UpdateProvider(type=CompactEntitySqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") CompactEntity record, @Param("example") CompactEntityExample example);

    /**
     *
     * @mbg.generated
     */
    @UpdateProvider(type=CompactEntitySqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(CompactEntity record);

    /**
     *
     * @mbg.generated
     */
    @Update({
        "update crm_compact",
        "set customer_id = #{customerId,jdbcType=INTEGER},",
          "bus_id = #{busId,jdbcType=INTEGER},",
          "compact = #{compact,jdbcType=INTEGER},",
          "compact_time = #{compactTime,jdbcType=DATE},",
          "party_a = #{partyA,jdbcType=VARCHAR},",
          "party_b = #{partyB,jdbcType=VARCHAR},",
          "text = #{text,jdbcType=VARCHAR}",
        "where compact_id = #{compactId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(CompactEntity record);
}